﻿using System;
using System.Collections.Generic;
using System.Text;

namespace BCGPSCommon
{
    /// <summary>
    /// 日期时间格式转换
    /// </summary>
    public class DateTimeTransfrom
    {
        /// <summary>
        /// 字符串转日期时间
        /// </summary>
        /// <param name="str">yyyy:MM:dd:HH:mm:ss:fff</param>
        /// <returns></returns>
        public static DateTime GetDateTime(string str)
        {
            var arr = str.Split(':');
            if (arr.Length == 7)
                return new DateTime(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), int.Parse(arr[3]), int.Parse(arr[4]), int.Parse(arr[5]), int.Parse(arr[6]));
            else
                return DateTime.Now;
                
        }
    }
}
